<?php class HeatherString extends HeatherObject {
	public static function ProcessUTFLiterals ($String) {
		// copyright and trademark
		$String = preg_replace ('[            \(tm\)   (?= \s | \p{P} | $) ]uix', '™', $String);
		$String = preg_replace ('[ (?<= \s)   \(c\)    (?= \s | $)         ]uix', '©', $String);
		// ellipsis
		$String = preg_replace ('[ (?<= \p{L} | \p{N})   \.\.\.   (?= \s | $) ]ux', '…', $String);
		// math: powers
		$String = preg_replace ('[ (?<= \p{L} | \p{N})   \^1   (?= \s | \p{P} | $) ]ux', '¹', $String);
		$String = preg_replace ('[ (?<= \p{L} | \p{N})   \^2   (?= \s | \p{P} | $) ]ux', '²', $String);
		$String = preg_replace ('[ (?<= \p{L} | \p{N})   \^3   (?= \s | \p{P} | $) ]ux', '³', $String);
		// math: fractions
		$String = preg_replace ('[ (?<= \s | ^)   1/3   (?= \s | \p{P} | $) ]ux', '⅓', $String);
		$String = preg_replace ('[ (?<= \s | ^)   2/3   (?= \s | \p{P} | $) ]ux', '⅔', $String);
		$String = preg_replace ('[ (?<= \s | ^)   1/8   (?= \s | \p{P} | $) ]ux', '⅛', $String);
		$String = preg_replace ('[ (?<= \s | ^)   1/4   (?= \s | \p{P} | $) ]ux', '¼', $String);
		$String = preg_replace ('[ (?<= \s | ^)   3/8   (?= \s | \p{P} | $) ]ux', '⅜', $String);
		$String = preg_replace ('[ (?<= \s | ^)   1/2   (?= \s | \p{P} | $) ]ux', '½', $String);
		$String = preg_replace ('[ (?<= \s | ^)   5/8   (?= \s | \p{P} | $) ]ux', '⅝', $String);
		$String = preg_replace ('[ (?<= \s | ^)   3/4   (?= \s | \p{P} | $) ]ux', '¾', $String);
		$String = preg_replace ('[ (?<= \s | ^)   7/8   (?= \s | \p{P} | $) ]ux', '⅞', $String);
		// math: operators
		$String = preg_replace ('[ (?<= \s | ^)   \+\-         (?= \p{N}) ]ux', '±', $String);
		$String = preg_replace ('[ (?<= \s)       ~ [=~]?      (?= \s)    ]ux', '≈', $String);
		$String = preg_replace ('[ (?<= \s)       ===          (?= \s)    ]ux', '≡', $String);
		$String = preg_replace ('[ (?<= \s)       <=           (?= \s)    ]ux', '≤', $String);
		$String = preg_replace ('[ (?<= \s)       >=           (?= \s)    ]ux', '≥', $String);
		$String = preg_replace ('[ (?<= \s)      ( <> | != )   (?= \s)    ]ux', '≠', $String);
		// dashes
		$String = preg_replace ('[ (?<= \p{N})           -              (?= \p{N})         ]ux', '−', $String);
		$String = preg_replace ('[ (?<= \p{N})           --             (?= \p{N})         ]ux', '–', $String);
		$String = preg_replace ('[ (?<= \p{L} | \p{N})      -{2,3}      (?= \p{L} | \p{N}) ]ux', '―', $String);
		$String = preg_replace ('[ (?<= \p{L} | \p{N})   \s -{1,3} \s   (?= \p{L} | \p{N}) ]ux', ' — ', $String);
		// quotes
		$String = preg_replace ('[ (?<= \s)                      ``       (?= \p{L} | \p{N}) ]ux', '“', $String);
		$String = preg_replace ('[ (?<= \s)                      ,,       (?= \p{L} | \p{N}) ]ux', '„', $String);
		$String = preg_replace ('[ (?<= \s)                      <<       (?= \p{L} | \p{N}) ]ux', '«', $String);
		$String = preg_replace ('[ (?<= \p{L} | \p{N} | \p{P})   \'\'     (?= \s | \p{P})    ]ux', '”', $String);
		$String = preg_replace ('[ (?<= \p{L} | \p{N})           >>       (?= \s | \p{P})    ]ux', '»', $String);
		// apostrophes
		$String = preg_replace ('[ (?<= \p{L} | \p{N} | \s | ^ )   \'   (?= \p{L} | \p{N})                  ]ux', '’', $String);
		$String = preg_replace ('[ (?<= \p{L} | \p{N} )            \'   (?= \p{L} | \p{N} | \p{P} | \s | $) ]ux', '’', $String);
		// template
#		$String = preg_replace ('[ (?<=  )   .   (?=  ) ]ux', '', $String);
		return ($String);
	}
	protected $_Data = '';
	protected $_KeepIntact = FALSE;
	public function __construct ($KeepIntact = FALSE) {
		$this->_KeepIntact = $KeepIntact;
	}
	public function Append ($String) {
		if (strlen ($String)) {
			strlen ($this->_Data) and $this->_Data .= ' ';
			$this->_Data .= $String;
		}
	}
	public function GetData () {
		return (property_exists ($this, '_Data') and is_scalar ($this->_Data)) ? $this->_Data : '';
	}
	protected function XMLData () {
		$Result = $this->GetData ();
		$this->_KeepIntact or $Result = self::ProcessUTFLiterals ($Result);
		return (strlen ($Result)) ? '<![CDATA['.str_replace (']]>', ']]&gt;', $Result).']]>' : '';
	}
} ?>